//
//  SCAlertView.m
//  Mutal
//
//  Created by TonyStart on 16/10/19.
//  Copyright © 2016年 com.wx. All rights reserved.
//

#import "SCAlertView.h"

@implementation SCAlertView


+(void)alertViewWithTitle:(NSString*)title{
    
    CGSize textSize = [title boundingRectWithSize:CGSizeMake(150, 150) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]} context:nil].size;
    
    
    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, textSize.width, textSize.height)];
    
    lable.text = title;
    lable.numberOfLines = 0;
    [lable sizeToFit];
    lable.textAlignment = NSTextAlignmentCenter;
    lable.center = CGPointMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/2);
    lable.textColor = [UIColor blackColor];
    lable.layer.cornerRadius = 5;
    lable.layer.masksToBounds = YES;
    lable.alpha = 0.0;
    lable.backgroundColor = [UIColor redColor];
    //将视图添加到WINDOW上
    [[UIApplication sharedApplication].keyWindow addSubview:lable];
    [UIView animateWithDuration:2.0 animations:^{
        lable.alpha = 1.0;
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:2.0 animations:^{
            lable.alpha = 0.0;
        } completion:^(BOOL finished) {
            //将视图从WINDOW移除
            [lable removeFromSuperview];
        }];
    }];
}
@end
